import { request } from "@/utils/service"

export const getUploadUrl  = (object:string, md5: string, type: string) => {
  return request({
    url: "admin/upload/oss",
    method: "post",
    params: {
      type
    },
    data: {
      object,
      hash: md5
    }
  })
}

export const saveFileUrl = (url: string, id: number, status: number = 1) => {
    return request({
      url: "admin/file/update",
      method: "post",
      data: {
        url,
        id,
        status: status
      }
    })
}

export const uploadFile = (file: File) => {
  const formData = new FormData()
  formData.append("file", file)
  return request({
    url: "admin/upload/local",
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  })
}